package com.game.play;

import com.game.cards.BaseCard;
import com.game.cards.Deck;
import com.game.cards.Hand;
import com.game.cards.MonsterCard;

public class Player {
	
	private String name;
	private Gender sex;
	private int lifePoints;
	private Deck currentDeck;
	private Hand hand;
	private Field field;
	private ActionQueue aq;

	public Player(String name, Gender sex, ActionQueue aq)
	{
		this.name = name;
		this.sex = sex;
		this.lifePoints= 8000;
		this.currentDeck = null;
		this.field = new Field(aq,this);
		this.aq = aq;
	
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Gender getSex() {
		return sex;
	}

	public void setSex(Gender sex) {
		this.sex = sex;
	}

	public int getLifePoints() {
		return lifePoints;
	}

	public void setLifePoints(int lifePoints) {
		if (this.lifePoints > lifePoints)this.aq.addEvent(Events.loselifepoints+","+this.name);
		if (this.lifePoints < lifePoints)this.aq.addEvent(Events.gainlifepoints+","+this.name);
		this.lifePoints = lifePoints;
	}
	public void setLifePointsSilent(int lifePoints)
	{
		this.lifePoints = lifePoints;
	}
	public Deck getCurrentDeck() {
		return currentDeck;
	}

	public void setCurrentDeck(Deck currentDeck) {
		this.currentDeck = currentDeck;
	}
	
	public Hand getHand() {
		return hand;
	}

	public void setHand(Hand hand) {
		this.hand = hand;
	}

	public void printHand()
	{
		int i = 1;
		System.out.println(this.name + "'s Hand:");
		for (BaseCard c : this.hand.getCards())
		{
			
			System.out.println("("+i+")" + c.getTitle());
			if (c instanceof MonsterCard)System.out.println("Attribute:" + ((MonsterCard) c).getAttribute());
			if (c instanceof MonsterCard)System.out.println("Type:" + ((MonsterCard) c).getType());
			if (c instanceof MonsterCard)System.out.println("Stars:" + ((MonsterCard) c).getStars());
			System.out.println(c.getDescription());
			if (c instanceof MonsterCard)System.out.println("ATK:" + ((MonsterCard) c).getAttack());
			if (c instanceof MonsterCard)System.out.println("DEF:" + ((MonsterCard) c).getDefense());
			System.out.println();
			i++;
			
		}
	}
	public void printHandSimple()
	{
		int i = 0;
		System.out.println(this.name + "'s Hand:");
		for (BaseCard c : this.hand.getCards())
		{
			System.out.print("("+i+")" + c.getTitle());
			if (c instanceof MonsterCard)System.out.print("Stars:" + ((MonsterCard) c).getStars());
			System.out.print("\n");
			i++;
		
		}
	}
	public void printGraveSimple()
	{
		int i = 0;
		System.out.println(this.name + "'s Graveyard:");
		for (BaseCard c : this.field.getGraveyard())
		{
			System.out.print("("+i+")" + c.getTitle());
			if (c instanceof MonsterCard)System.out.print("Stars:" + ((MonsterCard) c).getStars());
			System.out.print("\n");
			i++;
		
		}
	}
	public void draw(int amount)
	{
		this.hand.draw(amount, this.aq);
	}
	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}
	public ActionQueue getAq() {
		return aq;
	}

}
